home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / uartbug.zip / UART.ASM < prev    next >
Assembly Source File  |  1987-03-09  |  28KB  |  684 lines

  1.  
  2. interrupts    segment at 0h                      ;interrupt table segment
  3.               org 9h*4
  4. keyboard_int  dw 2 dup (?)                       ;interrupt 9 vector
  5. interrupts    ends
  6.  
  7. rom_bios_data segment at 40h                     ;ROM BIOS data area segment
  8.               org 0h
  9. com1base        dw      ?
  10. com2base        dw      ?             ;base addresses for com1 and com2
  11.               org 60h
  12. cursor_mode   dw ?                      ;starting and ending cursor scan lines
  13. rom_bios_data ends
  14.  
  15. rom           segment at 0F000h                  ;ROM segment
  16.               org 0FFFEh
  17. machine_id    db ?                ;ID byte identifies machine as PCjr or other
  18. rom           ends
  19.  
  20. code          segment para public 'code'         ;code segment
  21.               assume cs:code
  22.               org 100h
  23. begin:        jmp initialize                     ;goto initialization routine
  24.  
  25. com1    dw      ?
  26. com2    dw      ?       ;local storage for com1 and com2 base addresses
  27. adrs    dw      ?       ;current port address
  28. byteout db      0       ;byte to be sent when rgt arrow key pressed
  29.  
  30. column_count  dw ?                               ;width of window in columns
  31. cursor_type   dw ?                               ;cursor scan line definition
  32. cursor_pos    dw ?      ;position of cursor on entry to program
  33. setup_status  db 0              ;indicates if printer window is already active
  34. display_mode  dw ?                               ;current crt display mode
  35. vpage  equ this byte
  36. page_no       dw ?                               ;current displayed page
  37. attribute1    db 4Fh                             ;window attribute bytes
  38. attribute2    db 70h
  39.  
  40. display_table db 2Dh,29h        ;display re-enable values for modes 2 and 3
  41. video         dw 0B800h,0B900h,0BA00h,0BB00h     ;starting addresses of video
  42.                                                  ;memory for CGA pages 0 - 3
  43.  
  44. mono_video    dw 0B000h                          ;video segment address for
  45.                                                  ;monochrome adapter
  46.  
  47. old_kb_int              label dword
  48. old_keyboard_int        dw 2 dup (?)             ;storage for old keyboard
  49.                                                  ;interrupt vector
  50.  
  51. ;----------------------------------------------------------------------------
  52. ;Text of the Printer Setup Menu window.
  53. ;After initialization, text and attribute bytes are combined and stored
  54. ;in the WINDOW_TEXT area, and this area is used to store the contents of
  55. ;the screen that underlie the window when the window is called up.
  56. ;----------------------------------------------------------------------------
  57. window_buffer           label word
  58. buffer_text             db 201,26 dup (205),187
  59.                         db 186,'    COM1 UART REGISTERS   ',186
  60.                         db 199,26 dup (196),182
  61.                         db 186,' RX/TX reg*  =            ',186
  62.                         db 186,' Intrpt enbl*=            ',186
  63.                         db 186,' Intrpt ID   =            ',186
  64.                         db 186,' Line ctl    =            ',186
  65.                         db 186,' Modem ctl   =            ',186
  66.                         db 186,' Line stat   =            ',186
  67.                         db 186,' Modem stat  =            ',186
  68.                         db 186,' *baud if MSB of LCR set  ',186
  69.                         db 199,26 dup (196),182
  70.                         db 186,'  PGup/dn slct com port   ',186
  71.                         db 186,'  Up/down keys slct reg   ',186
  72.                         db 186,'  Rgt arrow writes reg    ',186
  73.                         db 186,'  Lft arrow reads reg     ',186
  74.                         db 186,'  ESC to exit             ',186
  75.                         db 186,'   BYTE TO SEND: 00 Hex   ',186
  76.                         db 200,26 dup (205),188
  77.                         db 532 dup (?)
  78. ;Storage area for the combination of text and attribute bytes that
  79. ;form the window image.
  80. window_bytes  label byte
  81. window_text   dw 532 dup (?)
  82.  
  83. ;---------------------------------------------------------------------------
  84. ;Execution comes here, to the main body of the program, when an interrupt 9
  85. ;is generated from the keyboard.  Registers are saved, then the keypress is
  86. ;checked and compared to the key combination that activates the menu window.
  87. ;---------------------------------------------------------------------------
  88. main          proc near
  89.               sti                                ;enable software interrupts
  90.               push ax                            ;save all registers
  91.               push bx
  92.               push cx
  93.               push dx
  94.               push si
  95.               push di
  96.               push ds
  97.               push es
  98.               push ax                   ;save ax for call to old routine
  99.               in al,0A0h                         ;re-enable NMI on PCjr
  100.               pop ax                             ;restore ax
  101.               pushf          ;simulate interrupt call to old keyboard routine
  102.               call old_kb_int                    ;call old routine
  103.               mov ah,2                   ;check status of the shift keys
  104.               int 16h
  105.               cmp al,14         ;***** CTRL,ALT,LEFT SHFT = activate pop up
  106.               je do_program                      ;yes, then skip exit routine
  107. ;Exit routine is the common point of exit for all routines in the program.
  108. exit:         pop es
  109.               pop ds
  110.               pop di
  111.               pop si
  112.               pop dx
  113.               pop cx
  114.               pop bx
  115.               pop ax
  116.               iret
  117.  
  118. ;Execution comes here when the proper key combination, Ctrl/Alt/LftShft, is
  119. ;pressed.  First task is to check whether or not the window is already open.
  120. do_program:   push cs                   ;set es and ds to the code segment
  121.               pop ds
  122.               push cs
  123.               pop es
  124.               cmp setup_status,0                 ;is the window already open?
  125.               jne exit                           ;yes, then ignore request
  126. ;----------------------------------------------------------------------------
  127. ;Check current video mode.  If it's mode 2, 3, or 7, then set the window
  128. ;status flag, store the mode number and page number, save the cursor type,
  129. ;and hide the cursor.  If any other display mode is active instead, ignore
  130. ;the request and exit.
  131. ;----------------------------------------------------------------------------
  132.               mov ah,15                          ;get page and mode numbers
  133.               int 10h                            ;al=mode, bh=page
  134.               cmp al,2                  ;is crt now in an acceptable mode?
  135.               je prog0                           ;yes, then continue
  136.               cmp al,3
  137.               je prog0
  138.               cmp al,7
  139.               je prog0
  140.               jmp exit                           ;no, then ignore request
  141. prog0:        mov setup_status,1                 ;set status flag to indicate
  142.                                                  ;that window is active
  143.               mov ah,0                           ;save mode number
  144.               mov display_mode,ax
  145.               push bx
  146.               mov bl,bh                 ;save page number for color displays
  147.               mov bh,0
  148.               mov page_no,bx
  149.               pop bx
  150.               mov ah,3                           ;get cursor type
  151.               int 10h
  152.               mov cursor_type,cx                 ;save it
  153.               mov cursor_pos,dx         ;save cursor position
  154.               mov ah,1                           ;hide the cursor until later
  155.               mov ch,20h
  156.               int 10h
  157. ;Preparatory routines are completed.  Now open the window by first saving the
  158. ;contents of video memory beneath the window and then writing the window text
  159. ;directly to memory.
  160.               mov bx,page_no             ;use bx as index into video segment
  161.                                          ;address table
  162.               cmp display_mode,7         ;manually adjust index for monochrome
  163.